home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / GDEVPRN.H < prev    next >
C/C++ Source or Header  |  1992-02-24  |  7KB  |  168 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gdevprn.h */
  21. /* Common header file for memory-buffered printers */
  22.  
  23. #include "memory_.h"
  24. #include "string_.h"
  25. #include "gs.h"
  26. #include "gsmatrix.h"            /* for gxdevice.h */
  27. #include "gxdevice.h"
  28. #include "gxdevmem.h"
  29. #include "gxclist.h"
  30.  
  31. /* Define the parameters for the printer rendering method. */
  32. /* If the entire bitmap fits in PRN_MAX_BITMAP, render in RAM, */
  33. /* otherwise use a command list with a size of PRN_BUFFER_SPACE. */
  34. /* (These are "properties" that can be changed by a Ghostscript program.) */
  35. #if arch_ints_are_short
  36. /* 16-bit machines have little dinky RAMs.... */
  37. #  define PRN_MAX_BITMAP 32000
  38. #  define PRN_BUFFER_SPACE 25000
  39. #else
  40. /* 32-bit machines have great big hulking RAMs.... */
  41. #  define PRN_MAX_BITMAP 10000000L
  42. #  define PRN_BUFFER_SPACE 1000000L
  43. #endif
  44.  
  45. /* Define the declaration macro for print_page procedures. */
  46. #define dev_proc_print_page(proc)\
  47.   int proc(P2(gx_device_printer *, FILE *))
  48.  
  49. /* Structure for generic printer devices. */
  50. /* This must be preceded by gx_device_common. */
  51. /* Printer devices are actually a union of a memory device */
  52. /* and a clist device, plus some additional state. */
  53. #define gx_prn_device_common\
  54.     byte skip[max(sizeof(gx_device_memory), sizeof(gx_device_clist)) -\
  55.           sizeof(gx_device) + sizeof(double) /* padding */];\
  56.     /* The following is required only for devices where */\
  57.     /* output_page is gdev_prn_output_page; */\
  58.     /* it is ignored for other devices. */\
  59.     dev_proc_print_page((*print_page));\
  60.         /* ------ The following items must be set before ------ */\
  61.         /* ------ calling the device open routine. ------ */\
  62.     long max_bitmap;        /* max size of non-buffered bitmap */\
  63.     long use_buffer_space;        /* space to use for buffer */\
  64.     char fname[80];            /* output file name */\
  65.         /* ------ End of preset items ------ */\
  66.     FILE *file;            /* output file */\
  67.     char ccfname[30];        /* clist file name */\
  68.     FILE *ccfile;            /* command list scratch file */\
  69.     char cbfname[30];        /* clist block file name */\
  70.     FILE *cbfile;            /* command list block scratch file */\
  71.     long buffer_space;    /* amount of space for clist buffer, */\
  72.                     /* 0 means not using clist */\
  73.     byte *buf;            /* buffer for rendering */\
  74.     int page_count;            /* # of pages printed so far */\
  75.     gx_device_procs *orig_procs;    /* original procs */\
  76.     gx_device_procs mod_procs    /* modified procs */
  77.  
  78. /* The device descriptor */
  79. typedef struct gx_device_printer_s gx_device_printer;
  80. struct gx_device_printer_s {
  81.     gx_device_common;
  82.     gx_prn_device_common;
  83. };
  84.  
  85. /* Macro for casting gx_device argument */
  86. #define prn_dev ((gx_device_printer *)dev)
  87.  
  88. /* Standard device procedures for printers */
  89. dev_proc_open_device(gdev_prn_open);
  90. dev_proc_output_page(gdev_prn_output_page);
  91. dev_proc_close_device(gdev_prn_close);
  92. dev_proc_map_rgb_color(gdev_prn_map_rgb_color);
  93. dev_proc_map_color_rgb(gdev_prn_map_color_rgb);
  94. dev_proc_get_props(gdev_prn_get_props);
  95. dev_proc_put_props(gdev_prn_put_props);
  96.  
  97. /* Macro for generating procedure table */
  98. #define prn_procs(proc_open, proc_output_page, proc_close)\
  99.   prn_color_procs(proc_open, proc_output_page, proc_close,\
  100.           gdev_prn_map_rgb_color, gdev_prn_map_color_rgb)
  101. /* See gdev_prn_open for explanation of the NULLs below. */
  102. #define prn_color_procs(proc_open, proc_output_page, proc_close, proc_map_rgb_color, proc_map_color_rgb) {\
  103.     proc_open,\
  104.     gx_default_get_initial_matrix,\
  105.     gx_default_sync_output,\
  106.     proc_output_page,\
  107.     proc_close,\
  108.     proc_map_rgb_color,\
  109.     proc_map_color_rgb,\
  110.     NULL,    /* fill_rectangle */\
  111.     NULL,    /* tile_rectangle */\
  112.     NULL,    /* copy_mono */\
  113.     NULL,    /* copy_color */\
  114.     NULL,    /* draw_line */\
  115.     gx_default_get_bits,\
  116.     gdev_prn_get_props,\
  117.     gdev_prn_put_props\
  118. }
  119.  
  120. /* The standard printer device procedures */
  121. /* (using gdev_prn_open/output_page/close). */
  122. extern gx_device_procs prn_std_procs;
  123.  
  124. /* Macro for generating the device descriptor. */
  125. /*
  126.  * The computations of page width and height in pixels should really be
  127.  *    ((int)(page_width_inches*x_dpi))
  128.  * but some compilers (the Ultrix 3.X pcc compiler and the HPUX compiler)
  129.  * can't cast a computed float to an int.  That's why we specify
  130.  * the page width and height in inches/10 instead of inches.
  131.  */
  132. #define prn_device(procs, dev_name, width_10ths, height_10ths, x_dpi, y_dpi, l_margin, b_margin, r_margin, t_margin, color_bits, print_page) {\
  133.     sizeof(gx_device_printer),\
  134.     &procs,\
  135.     dev_name,\
  136.     (int)((long)width_10ths * x_dpi / 10),    /* width */\
  137.     (int)((long)height_10ths * y_dpi / 10),    /* height */\
  138.     x_dpi,\
  139.     y_dpi,\
  140.     l_margin, b_margin, r_margin, t_margin,\
  141.        {    (color_bits > 1 ? 3 : 1),    /* num_components */\
  142.         ((color_bits > 1) & (color_bits < 8) ? 8 : color_bits),    /* depth */\
  143.         (color_bits >= 8 ? 255 : 1),    /* max_gray */\
  144.         (color_bits >= 8 ? 255 : color_bits > 1 ? 1 : 0),    /* max_rgb */\
  145.         (color_bits >= 8 ? 5 : 2),    /* dither_gray */\
  146.         (color_bits >= 8 ? 5 : color_bits > 1 ? 2 : 0),    /* dither_rgb */\
  147.        },\
  148.     0,        /* not initialized yet */\
  149.       { 0 },    /* skip */\
  150.     print_page,\
  151.     PRN_MAX_BITMAP,\
  152.     PRN_BUFFER_SPACE,\
  153.       { 0 }        /* fname */\
  154. }
  155.  
  156. /* Common procedures defined in gdevprn.c */
  157. int gdev_prn_open_printer(P1(gx_device *));
  158. uint gdev_prn_bytes_per_scan_line(P1(gx_device_printer *));
  159. int gdev_prn_copy_scan_lines(P4(gx_device_printer *, int, byte *, uint));
  160. int gdev_prn_get_bits(P5(gx_device_printer *, int, byte *, uint, int));
  161. int gdev_prn_close_printer(P1(gx_device *));
  162.  
  163. /* BACKWARD COMPATIBILITY */
  164. #define gdev_mem_bytes_per_scan_line(dev)\
  165.   gdev_prn_bytes_per_scan_line((gx_device_printer *)(dev))
  166. #define gdev_prn_transpose_8x8(inp,ils,outp,ols)\
  167.   memflip8x8(inp,ils,outp,ols)
  168.